473,467 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Default Button Click On Enter KeyPress On Web Form

I have an asp.net 1.1/C# web form with a text box server control and
one button server control. Users can type in text to search and then
click the button to start the search. I want them to be able to type
in text and then just hit the Enter key instead of having to click the
button.

Currently, an Enter keypress causes a post back, but it does not fire
the event handler for the button click. How can I get this to work?

Feb 28 '07 #1
1 4625
Not sure if this is "right", but what I do is do the update in the load
event; but only if the cancel button hasn't been clicked;

if (Page.IsPostback)
{
if (Request.Form["cmdCancel"] != null)
return;

// Save the data
}

So pressing [enter] will trigger a postback that will save, as will pressing
your submit button. Pressing the cancel button causes the postback but the
update code is not run.

Would be interested if someone has a "proper" way.

"Joey" <jo*********@topscene.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
>I have an asp.net 1.1/C# web form with a text box server control and
one button server control. Users can type in text to search and then
click the button to start the search. I want them to be able to type
in text and then just hit the Enter key instead of having to click the
button.

Currently, an Enter keypress causes a post back, but it does not fire
the event handler for the button click. How can I get this to work?

Feb 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Fainveits | last post by:
Does anybody know how to control enter button on the web form? It seems to if the user hits enter button at run time then it fires submit button click event. I have also noticed that if the page...
3
by: Philip Townsend | last post by:
I have an aspx page that contains 2 user controls, each containing a seperate textbox and button. I would like to specify that one of the buttons recieve focus when the page loads. Also, I would...
2
by: Bratislav Jevtic | last post by:
hi, how to make some push button default on the form? for instance, I've got 2 buttons (Submit, Cancel). submit is on the left, cancel on the right side. on enter key pressed, cancel button is...
4
by: RA | last post by:
Hi I have asp.net web app. When a user clicks the enter key when he is viewing the aspx web form, it jumps to the starting web form. How can I handle the user hitting the enter key and to...
12
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items...
5
by: Dundealing | last post by:
I have a single button on my form, and when I press the Enter key while a TextBox has focus I want the Button.Click event to fire. Is there a simple way to do this ?
3
by: graphicsxp | last post by:
Hi, I've written some javascript function so that if a textbox has the focus and the user press enter, it triggers a click on a button 'associated' to this textbox (see code at the end) The...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
6
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.